package com.general.framework.cc.thread;

public class T7 {
    public static void main(String[] args) {
        T7A t7A = new T7A();
        new Thread(()->{
            while (true){
                System.out.println("now in 111==="+Thread.currentThread().getName()+", num ==="+t7A.genNum(1));
                try {
                    Thread.sleep(100);
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }).start();
        new Thread(()->{
            while (true){
                System.out.println("now in 222==="+Thread.currentThread().getName()+", num ==="+t7A.genNum(2));
                try {
                    Thread.sleep(100);
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }).start();
        new Thread(()->{
            while (true){
                System.out.println("now in 333==="+Thread.currentThread().getName()+", num ==="+t7A.genNum(3));
                try {
                    Thread.sleep(100);
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }).start();
        new Thread(()->{
            while (true){
                System.out.println("now in 444==="+Thread.currentThread().getName()+", num ==="+t7A.genNum(4));
                try {
                    Thread.sleep(100);
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }).start();
    }
}


class T7A{
    private int num;
    public int genNum(){
        return num;
    }
    public int genNum(int i){
        num = i;
        return num;
    }
}